//
//  TTMacro.h
//  Tint
//
//  Created by Kevin Wu on 11/8/11.
//  Copyright (c) 2011 Telligenty. All rights reserved.
//


/*
 * Singleton
 */
#define TTSynthesizeSingleton(classname) \
+ (classname *)sharedObject { \
static classname *shared##classname = nil; \
if (shared##classname == nil) shared##classname = [[self alloc] init]; \
return shared##classname; \
} \
- (id)copyWithZone:(NSZone *)zone { return self; } \
- (id)retain { return self; } \
- (NSUInteger)retainCount { return NSUIntegerMax; } \
- (oneway void)release { } \
- (id)autorelease { return self; }

/*
 * Memory management
 */
#define TTRetain(__new, __old) { [__new retain]; [__old release]; __old = __new; }
#define TTCopy(__new, __old) { [__old autorelease]; __old = [__new copy]; }
#define TTRelease(__pointer) { [__pointer release]; __pointer = nil; }
#define TTReleaseCF(__ref) { if (nil != (__ref)) { CFRelease(__ref); __ref = nil; } }
#define TTInvalidateTimer(__timer) { [__timer invalidate]; __timer = nil; }

/*
 * TimeInterval
 */
#define TTTimeIntervalMinute() (60)
#define TTTimeIntervalHour() (60 * 60)
#define TTTimeIntervalDay() (24 * 60 * 60)
#define TTTimeIntervalWeek() (7 * 24 * 60 * 60)

